package logic

import (
	"context"
	"gorm.io/gorm"
	"vip-shop/model"

	"vip-shop/shoprpc/internal/svc"
	"vip-shop/shoprpc/shoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectLogic {
	return &PerfectLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PerfectLogic) Perfect(in *shoprpc.PerfectRequest) (*shoprpc.PerfectResponse, error) {
	// todo: add your logic here and delete this line

	user := model.User{
		Model: gorm.Model{
			ID: uint(in.Id),
		},
		Age:     int(in.Age),
		Address: in.Address,
		HandImg: in.HandImg,
	}
	model.DB.Debug().Updates(&user)
	return &shoprpc.PerfectResponse{
		UserId: int64(user.ID),
	}, nil
}
